<?php
session_start ();

$_SESSION ['pathway'] = '.';
$_SESSION ['pathway_js'] = '';
$_SESSION ['pathway_uploads'] = './uploads';

if (! isset ( $_SESSION ['id'] )) {
	header ( 'Location: http://localhost/SPATAX_beta/index.php' );
} else {
	
	// print_r($_POST);
	// print_r($_FILES);
	
	require_once ("./requetes/last_login.php");
	require_once ("./commun/ouvre_base.php");
	require_once ("./requetes/recup_niveau.php");
	
	include ("./header.php");
	
	$date = getdate ();
	$_SESSION ['date'] = $date ['year'] . '-' . $date ['mon'] . '-' . $date ['mday'];
	
	if (isset ( $_SESSION ['id'] )) {
		
		if (isset ( $_FILES ['tree_file'] ) and $_FILES ['tree_file'] ['error'] == 0) {
			move_uploaded_file ( $_FILES ['tree_file'] ['tmp_name'], $_SESSION ['pathway_uploads'] . '/pedigree/' . basename ( $_FILES ['tree_file'] ['name'] ) );
			chmod ( $_SESSION ['pathway_uploads'] . '/pedigree/' . basename ( $_FILES ['tree_file'] ['name'] ), 0777 );
			
			echo "<script>window.location.href=\"./start.php\"</script>";
		} else {
			
			?><form action='./upload_family_tree.php' method='post'
	enctype='multipart/form-data'>
	<table class='principale'>
		<tr>
			<td>Select your tree file :</td>
			<td><input type='file' id='tree_file' name='tree_file' /><input
				type='submit' value='Upload' />
			
			<td>Format :
				<p class='important'>code1-code2-code3-code4.ppt</p> <br />If the
				file already exists, it <u>will be overwrite</u>
			</td>
		</tr>

	</table>
</form><?php
		}
	} else {
		echo "<table class='principale'><tr><td>Page not found</td></tr>";
		echo "<tr><td><a href=" . $_SESSION ['pathway'] . "../index.php\">Back</a></td></tr></table>";
	}
	
	include ("./footer.php");
}
?>
